// 病人退费

import React from 'react';
import moment from 'moment';
import { Select, Input, Row, Col, Button, Spin, Divider, Popconfirm, message, Icon, Form, DatePicker, Table, Tabs, Modal, InputNumber, Tooltip } from 'antd';
import { $http } from 'containers/config/https';
import InquiryFeeRecordModal from './component/InquiryFeeRecordModal'
import './style/style.less'
import { Keup, ArraySome, INSUYBUtil, Util } from '../../../tools/index';
import TipHeader from './component/TipHeader'
import WasteAndReclaimed from './component/WasteAndReclaimed'
import { $loadTemplate } from '../../lodop/Common/Print.js';
import ReadCard from '../../../components/readcard/ReadCard';
import fetchJsonp from 'fetch-jsonp';
import $ from 'pages/workstation/component/js/jquery-3.2.1.min.js';
import store from '../../../store';
import RangeDatePicker from 'components/rangePicker/index';
import PublicModalTable from 'pages/common/PublicModalTable';

// 组件const
const { Option } = Select;
const { RangePicker } = DatePicker;
const dateFormat = 'YYYY-MM-DD' || undefined;
const { Search } = Input;

export default class PatientRefund extends React.Component {

    constructor(props) {
        super(props)
        this.updateMoney = this.updateMoney.bind(this);
        let userData = JSON.parse(sessionStorage.getItem('userData'));
        this.state = {
            userData,
            userInfo: {}, // 用户数据
            cardType: '', // 卡类型
            cardTypeData: [], // 卡类型
            cardNo: '', // 卡号
            patNo: '', // 登记ID号
            invNo: '', // 发票号
            dataTable: [], // table数据
            modalShow: false, //  收费弹框的显示
            recordinvID: '', //收款记录发票记录服务的ID
            invType: '',//收款记录发票记录服务的类型
            PayReasonDr: '', // 结算类型
            reasonCode: "",
            settlementTypeData: [], // 结算类型数据
            invoice: '',  // 当前发票号
            IfAbortFlag: '', // 权限判断
            IfStrikeFlag: '',  // 权限判断
            refundPatAmt: 0,  // 退费总额
            payingPatAmt: 0,  // 剩余应付
            payReasonDesc: '',// 按钮文字
            modalShowDeletePay: false, //是否作废弹框
            modalShowPay: false, // 退费弹框
            chargeRecodeId: '', // 交款记录id
            parkRecordDrinfo: '', // 退费的负付款记录
            moneyData: {}, //金额对象
            otherPayData: [], //其他付款方式
            otherPay: '', //其他支付方式
            otherPayDis: false, //其他支付方式不可选
            otherPayMoney: '0.00', // 其他支付金额
            cashInCashVal: '0.00', // 实收现金
            zeroPay: '0.00', // 找零
            accountPayWayId: '', // 院内账户支付方式id
            payWayCashId: '', // 现金支付方式id
            unitsList: [], // 合作单位列表
            unitsListVal: '', //合作单位
            refundordIDStr: '',  // 退费医嘱
            // refundDefaultPaywayID: '',  //新支付方式来自下拉框
            disBtton: false, // 按钮点击许可
            StartDate: moment().subtract(7, "days").format('YYYY-MM-DD'),  // //开始日期
            EndDate: moment().format('YYYY-MM-DD'),  // //结束日期
            payWData: [],
            FPatAmt: '',
            NewPatAmt: '',
            OldPatAmt: '',
            payArr: [],
            newPaywAmtNum: 0,
            INVID: '',
            INV: '',
            compleRecordIDinfo: '',  // //compleRecordIDinfo
            invIDinfo: '',  // //invIDinfo
            columns: [],
            languageData: {}, // 国际化语言包
            language: {},   // 国际化语言
            languageCode: JSON.parse(window.sessionStorage.userData).language, // 国际化语言标识
            readModeI: true,
            readModeR: true,
            invNum: '0',
            OPInsuType: '',// OPInsuType
            insuPayID: '',// insuPayID
            personalData: '', // personalData
            qrCode: "",
            cardNumber: "",
            cardShow: false,
            modalPageSize: 10,
            modalPage: 1,
            modalData: [],
            INSUICDCode: '',    // 医保诊断code
            INSUICDDesc: '',    // 医保诊断描述
            searchCode: '',
            comepnCodeList: [],
            comepnCode: '',
            divdata: [],		// 患者医保数据
            insuInfoShow: false,
            readCarddata: {},	// 读卡信息
            groupConfig: '',
            xnhjgList: [],
            xnhjgCode: '',
            xnhBCTYPEList: [],
            xnhBCTYPE: "",
            insuAdmdvs: ""
        }
        this.modalColumns = [{
            title: 'ICD诊断代码',
            dataIndex: 'code',
            key: 'code'
        }, {
            title: 'ICD诊断描述',
            dataIndex: 'descripts',
            key: 'descripts'
        }]

    }

    componentDidMount() {
        for (var i = 0; i < document.querySelectorAll("div.maxHeight div.ant-table-body").length; i++) {
            document.querySelectorAll("div.maxHeight div.ant-table-body")[i].style.height = store.getState().tableHeight.y + 'px';
        }

        this.cardTypeList() //卡类型
        this.initJuris() //权限
        this.ordList1()
        this.focusInput()
    }

    //获取光标
    focusInput = () => {

        let { focusType } = this.state
        if (focusType === 'CardNo') {
            const { input } = this.cardNoInput;
            input.focus();
        } else {
            const { input } = this.patNoInput;
            input.focus();
        }


    }

    // 权限
    initJuris = () => {
        var data = {
            params: [{
                logonHospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id
                logonGroupID: JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                logonUserID: JSON.parse(window.sessionStorage.userData).userID, //人员id
                invTypeCode: 'O',  // 类型

            }]
        }
        $http.post('urlS', this, {
            code: "05210001",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        invoice: res.currentInvNoInfo,  // 当前发票号
                        IfAbortFlag: res.groupConfig.IfAbortFlag,  // 权限判断
                        IfStrikeFlag: res.groupConfig.IfStrikeFlag,  // 权限判断
                        otherPayData: res.groupConfig.HBOPConfigPaymode[0].OPCharge || [],  // 其他付款方式
                        invNum: res.invNum || '0',  // 发票数剩余
                        groupConfig: res.groupConfig,

                    });
                    if (res.groupConfig.IfChargeFlag === 'Y') {
                        if (res.groupConfig.IfInvNo === 'Y' && res.currentInvNoInfo.split('^')[0] !== '0') {
                            message.error('该收费员无发票号')
                        }
                    } else {
                        message.error('无收费权限')
                        this.setState({
                            disabledInput: true,  // 收费权限
                        });
                    }
                }
            }
        });

    }


    //卡类型
    cardTypeList = () => {
        var data = {
            params: [{
                cardTypeFlag: 1,
            }]
        }

        $http.post('urlS', this, {
            code: "03030005",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    let cardDeffault = res.cardType.filter((item) => {
                        return item.defaultFlag === 'Y';
                    })
                    this.setState({
                        cardType: cardDeffault[0].id, // 默认卡
                        cardTypeData: res.cardType,  // 用户数据
                    }, () => {
                        this.CardTypeChange(this.state.cardType)
                    });
                }
            }
        });
    }


    // 查询条件 --- 卡类型·
    cardType = (e) => {
        this.setState({ cardType: e }, () => {
            this.CardTypeChange(e)
        });
    }
    // 查询条件 --- 卡号
    cardNo = (e) => {
        let { readModeI } = this.state
        if (!readModeI) {
            return false
        }
        this.setState({ cardNo: e.target.value });
    }

    // Card
    CardTypeChange = (e) => {
        if (!e) {
            return false
        }
        let { cardTypeData } = this.state
        let readMode = cardTypeData.filter((item, i) => {
            return item.id == e;
        })

        switch (readMode[0] && readMode[0].readMode) {
            // 只可input
            case 'I':
                this.setState({
                    readModeI: true,
                    readModeR: false,
                    cardNo: "",

                })
                break;
            // 只可读卡
            case 'R':
                this.setState({
                    readModeR: true,
                    readModeI: false,
                    cardNo: "",
                })
                break;
            // 皆可
            default:
                this.setState({
                    readModeI: true,
                    readModeR: true,
                    cardNo: "",
                })
                break;
        }

    }


    // 查询条件 --- 登记号
    patNo = (e) => {
        this.setState({ patNo: e.target.value });
    }

    // 查询条件 --- 发票号
    invNo = (e) => {
        this.setState({ invNo: e.target.value });
    }

    // 查询条件 --- 结算类型
    PayReasonDr = (e) => {
        let itemselect = this.state.settlementTypeData.filter((item) => {
            return item.id == e;
        })

        this.setState({ PayReasonDr: e, OPInsuType: itemselect[0] ? itemselect[0].OPInsuType : '', reasonCode: itemselect[0].code });
    }


    // 回车查询
    patNodownE = (e, type) => {

        if (e.keyCode === 13) {
            this.searchUser(type)
        }
    }

    // 读卡 --- 根据卡号取病人信息
    handleReadCard = (value, event) => {
        let { readModeI, readModeR, cardType } = this.state
        if (event.keyCode) {
            if (readModeI) {
                this.searchUser('cardNo'); // 重新调用查询接口
            }
            return false
        }
        if (readModeR) {
            this.readCard.ReadCard(cardType, "R", (json) => {
                let patNo = json && json.patInfo ? json.patInfo.patNo : ''
                this.setState({ patNo, cardNo: json.cardNo }, () => {

                    //this.searchUser('cardNo'); // 重新调用查询接口
                    if (patNo) {
                        this.searchUser('patNo'); // 重新调用查询接口
                    } else {
                        this.searchUser('cardNo'); // 重新调用查询接口
                    }
                })
            })
        }

    }

    // // 回车读卡 --- 根据卡号取病人信息
    // handleReadCarddownE = (e, type) => {
    //     if (e.keyCode === 13) {

    //         this.searchUser('cardNo') // 读卡 --- 根据卡号取病人信息
    //     }
    // }

    // 读卡
    searchUser = (type) => {

        var data;
        let { cardType, cardNo, patNo, cardTypeData, invNo } = this.state
        if (!type) {   // 查询全部
            data = {
                params: [{
                    "invNo": invNo, // 发票号
                    "number": patNo || '', // 登记号/身份证号
                    "cardTypeID": cardType,   //卡类型id
                    "cardNo": cardNo,    //卡号
                }]
            }
        }




        if (type === 'patNo') {
            data = {
                params: [{
                    "invNo": '', // 发票号
                    "number": patNo || '', // 登记号/身份证号
                    "cardTypeID": "",   //卡类型id
                    "cardNo": "",    //卡号
                }]
            }


            if (patNo === '') {
                return false
            }
        }

        if (type === 'cardNo') {
            data = {
                params: [{
                    "invNo": '', // 发票号
                    "number": '', // 登记号/身份证号
                    "cardTypeID": cardType || '',     //卡类型id
                    "cardNo": cardNo || '', //卡号
                }]
            }

            if (cardNo === '') {
                return false
            }
            if (cardType === '') {
                message.error('请选择卡类型')
                return false
            }


            let cardTypeFilter = cardTypeData.filter(function (item) {
                return item.id == cardType;
            })

            let zeroLength = cardTypeFilter[0].cardLength

            if (zeroLength && zeroLength != '' && parseFloat(zeroLength) != 0) {
                this.setState({
                    cardNo: ArraySome.addPreZero(cardNo, zeroLength)
                })
                data = {
                    params: [{
                        "invNo": '', // 发票号
                        "number": '', // 登记号/身份证号
                        "cardTypeID": cardType || '',     //卡类型id
                        "cardNo": ArraySome.addPreZero(cardNo, zeroLength) || '', //卡号
                    }]
                }
            }


        }

        if (type === 'invNo') {
            data = {
                params: [{
                    "invNo": invNo, // 发票号
                    "number": '', // 登记号/身份证号
                    "cardTypeID": "",   //卡类型id
                    "cardNo": "",    //卡号
                }]
            }

            if (invNo === '') {
                return false
            }
        }


        $http.post('urlS', this, {
            code: "05210012",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.setState({
                        userInfo: res.data || {},  // 用户数据
                        settlementTypeData: res.data.admReason || [],  // 结算类型
                        patNo: res.data.patNo || '',  // ID
                        dataTable: [],
                    }, () => {
                        if (type !== 'invNo') {
                            this.setState({
                                modalShow: true //  收费弹框的显示
                            })
                        } else {
                            // this.setState({
                            //     recordinvID: data.recordID, //收款记录发票记录服务的ID
                            //     invType: data.invType,//收款记录发票记录服务的类型
                            // }, () => {
                            //     this.ConReDocOrderInformationService('invNo')     //查询退费医嘱信息服务
                            // })

                        }
                    });

                }
            }
        });
    }
    onCardChange = (e) => {

        this.setState({ cardNumber: e.target.value });
    }
    onqrCodeChange = (e) => {
        this.setState({ qrCode: e.target.value });
    }
    //查询退费医嘱信息服务
    ConReDocOrderInformationService = (type) => {
        let data = {
            params: [{
                "invNo": this.state.invNo || '', // 发票号
                "recordinvID": this.state.recordinvID || '', //收款记录发票记录服务的ID
                "invType": this.state.invType || '',//收款记录发票记录服务的类型
                "payReasonNewID": this.state.PayReasonDr || '',//结算类别
            }]
        }


        $http.post('urlS', this, {
            code: "05210018",
            data: data,
            success: function (res) {
                console.log("05210018", res);
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    let result = res.returnOrdInfoArr;
                    for (var i = 0; i < result.length; i++) {
                        result[i].key = i;
                    }
                    if (res.refundFlag === 'A' && this.state.IfAbortFlag === 'N') { // 权限判断
                        message.error('无权限')
                        return false
                    }
                    if (res.refundFlag === 'S' && this.state.IfStrikeFlag === 'N') { // 权限判断
                        message.error('无权限')
                        return false
                    }
                    this.setState({
                        dataTable: result,  // 退费申请列表
                        refundPatAmt: parseFloat(res.refundPatAmt).toFixed(2),  // 退费总额
                        payingPatAmt: parseFloat(res.payingPatAmt).toFixed(2),  // 剩余应付
                        PayReasonDr: res.payReasonID,  // 结算类型
                        payReasonDesc: res.refundFlagDesc,  // 按钮文字
                        refundordIDStr: res.refundordIDStr,  // 退费医嘱
                        disInvType: res.invType,
                        // refundDefaultPaywayID: res.refundDefaultPaywayID, //新支付方式来自下拉框
                        // insuAdmdvsList:res.admdvs,
                    }, () => {
                        let itemselect = this.state.settlementTypeData.filter((item) => {
                            return item.id == res.payReasonID;
                        })
                        this.setState({
                            reasonCode: itemselect[0].code
                        })

                        // let defaultSelect = this.state.otherPayData.filter((item) => {
                        //     return item.paywID === res.refundDefaultPaywayID
                        // })

                        // if (defaultSelect.length < 1) {
                        //     this.setState({
                        //         refundDefaultPaywayID: this.state.otherPayData[0] ? this.state.otherPayData[0].paywID : ''
                        //     })
                        // }
                    });

                }
            }
        });
    };

    // 弹框关闭
    handleCancel = () => {
        this.setState({
            modalShow: false,
            modalShowPay: false,
            disBtton: false, // 按钮点击许可
            modalShowDeletePay: false
        });
        this.focusInput()
    };

    // 历史记录子组件传值到父组件
    updateParent = (data) => {
        this.handleCancel() // 弹框关闭

        this.setState({
            recordinvID: data.recordID, //收款记录发票记录服务的ID
            invType: data.invType,//收款记录发票记录服务的类型
            insuPayID: data.insuPayID,//收款记录发票记录服务的类型
            fphm: data.fphm,
            fpSource: data,
        }, () => {
            this.ConReDocOrderInformationService('!invNo')     //查询退费医嘱信息服务
        })

    }


    // 清空
    clearnFile = () => {
        this.setState({
            userInfo: {}, // 用户数据
            cardNo: '', // 卡号
            patNo: '', // 登记ID号
            invNo: '', // 发票号
            dataTable: [], // table数据
            modalShow: false, //  收费弹框的显示
            recordinvID: '', //收款记录发票记录服务的ID
            invType: '',//收款记录发票记录服务的类型
            PayReasonDr: '', // 结算类型
            reasonCode: "",
            settlementTypeData: [], // 结算类型数据
            IfAbortFlag: '', // 权限判断
            IfStrikeFlag: '',  // 权限判断
            refundPatAmt: 0,  // 退费总额
            payingPatAmt: 0,  // 剩余应付
            payReasonDesc: '',// 按钮文字
            // refundDefaultPaywayID: '',// 其他支付方式
            disBtton: false, // 按钮点击许可
            // StartDate: undefined,  // //开始日期
            // EndDate: undefined,  // //结束日期
            payWData: [],
            FPatAmt: '',
            NewPatAmt: '',
            OldPatAmt: '',
            payArr: [],

            newPaywAmtNum: 0,
            INVID: '',
            INV: '',
            compleRecordIDinfo: '',  // //compleRecordIDinfo
            invIDinfo: '',  // //invIDinfo
            readModeI: true,
            readModeR: true,
            invNum: '0',
            xnhBCTYPEList: [],
            xnhBCTYPE: "",

        }, () => this.focusInput())

    }

    // 退费
    payButton = () => {
        /**
         * @ByYQL：弹框确认是否作废或作废重收，确认后执行原有代码 payButtonModal()
         * Create 2021-10-12
         */

        if (this.state.payReasonDesc == '作废' || this.state.payReasonDesc == '作废重收') {
            this.setState({
                modalShowDeletePay: true
            })
        } else {
            this.payButtonModal()
        }
    }
    payButtonModal = () => {
        if (this.state.PayReasonDr === '' || !this.state.PayReasonDr) {
            message.error('请选择结算类型')
            return false
        }
        // if (this.state.refundDefaultPaywayID === '' || !this.state.refundDefaultPaywayID) {
        //     message.error('请选择其他付款方式')
        //     return false
        // }

        this.setState({
            disBtton: true, // 按钮点击许可
        })

        let { insuPayID, PayReasonDr } = this.state
        let itemselect = this.state.settlementTypeData.filter((item) => {
            return item.id == PayReasonDr;
        })
        this.setState({
            OPInsuType: itemselect[0] ? itemselect[0].OPInsuType : '',
            // OPRefundInsuType: itemselect[0] ? itemselect[0].OPRefundInsuType : '',
        }, () => {
            var OPInsuType = this.state.OPInsuType
            // var OPRefundInsuType = this.state.OPRefundInsuType
            if (OPInsuType === 'Y' || insuPayID != '') {
                // /**
                //  * @ByYQL: 新增字段OPRefundInsuType 判断门诊医保退费是否刷卡、
                //  * IPRefundInsuType判断住院退费是否刷卡（暂未使用）
                //  * Create 2021-12-28
                //  */
                // if(OPRefundInsuType === 'Y'){
                this.setState({ cardShow: true, cardNumber: "", qrCode: "" });
                // }else{
                //     this.payButtonData()
                // }
            }
            else {
                this.payButtonData()
            }
        })
    }
    payButtonModalCancel = () => {
        this.setState({
            modalShowDeletePay: false
        })
    }

    YBInputSure = () => {
        this.setState({ cardShow: false }, () => {
            this.syLoading("请等待");
        });
    }
    syLoading = async (title) => {

        let { PayReasonDr } = this.state
        let openModal = Modal.info({
            title: title,
            content: <Spin size="large" />,
            okText: "",
            onOk() { },
        });
        try {
            let itemselect = this.state.settlementTypeData.filter((item) => {
                return item.id == PayReasonDr;
            })

            /**
             * @ByYQL: 读医保卡或医保电子凭证
             * Create 2021-12-29
             */
            /**
             * @ByYQL: 统一基线版前端调用DLL封装
             * iShowForm ： 是否弹窗 0 不弹  1 弹
             * iCardType ： 01：电子凭证   02：身份证   03：社保卡
             * operatorId ：收款员工号
             * operatorName : 	收款员姓名
             * officeId ：科室id
             * officeName ： 科室名称
             * patID : 病人id
             * Create 2022-1-24
             */
            var certType = this.state.certType
            var certNo = this.state.certNo
            //----------------------------------------
            let dllInputdata = {
                "iShowForm": 0,
                "iCardType": certType,
                "operatorId": JSON.parse(window.sessionStorage.userData).userCode,
                "operatorName": JSON.parse(window.sessionStorage.userData).userName,
                "officeId": JSON.parse(window.sessionStorage.userData).locID,
                "officeName": JSON.parse(window.sessionStorage.userData).locDesc,
                "patID": this.state.userInfo.patID || ''
            }
            // if( certType =="03" || certType =="01"){
            var retStr = await INSUYBUtil.ReadInsuCard(dllInputdata);
            let resObj = JSON.parse(retStr);
            console.log('retStr', retStr);
            if (resObj.errorCode != "0") {
                message.warn(resObj.errorMessage);
                openModal.destroy();
                return
            }
            // cardSN=resObj.result.cardsn
            certNo = resObj.result.cardInfo
            // }
            //----------------------------------------
            // let dllData = {"admID":this.state.userInfo.admID || '',"reasonCode":this.state.PayReasonDr,"MdtrtCertType":this.state.certType,"bussType":"M6"}
            // var retStr= await INSUYBUtil.ReadInsuCard(JSON.stringify(dllData));
            // let resObj = JSON.parse(retStr);
            // console.log( 'retStr',retStr );
            // if(resObj.errorCode!="0"){
            //     message.warn(resObj.errorMessage);
            //     openModal.destroy();
            //     return
            // }
            // // cardSN=resObj.result.cardsn
            // certNo = resObj.result.cardInfo
            //----------------------------------------
            this.setState({
                certType,
                certNo,
                // cardSN
            })

            let data = {
                "params": [{
                    "userID": JSON.parse(window.sessionStorage.userData).userID,
                    "patID": this.state.userInfo.patID || '',  //病人id
                    "reasonCode": itemselect[0].code,
                    "patName": this.state.userInfo.patName || '',  //病人姓名
                    "certNo": this.state.certNo,
                    "certType": this.state.certType,
                    "locID": JSON.parse(window.sessionStorage.userData).locID,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                    "ip": React.$getSessionData('ipConfig').ipv4 || '',
                    "mac": React.$getSessionData('ipConfig').mac || '',
                    // "insuAdmvs":this.state.insuAdmdvs,
                    "recordinvID": this.state.recordinvID || '', //收款记录发票记录服务的ID
                    "invNo": this.state.invNo || '', // 发票号
                    "insuPayID": this.state.insuPayID || ''
                }]
            };
            let hisdataobj = await INSUYBUtil.GoTOHISHttp(data, "05020001");    //调用his接口
            if (hisdataobj.errorCode != '0') {
                message.warn(hisdataobj.errorMessage);
                openModal.destroy();
            } else {
                let errorCode = hisdataobj.errorCode;
                if (errorCode === '0') {
                    let divdata = hisdataobj.result.patYBData ? hisdataobj.result.patYBData : [];
                    let insuTypeList = hisdataobj.result.insuTypeData
                    let insuMedTypeList = hisdataobj.result.insuMedTypeData
                    let diseCodeList = hisdataobj.result.diseCodeData
                    let birctrlTypeList = hisdataobj.result.birctrlTypeData
                    let comepnCodeList = []
                    this.setState({
                        comepnCodeList,
                        divdata,
                        insuInfoShow: true,
                        readCarddata: divdata,
                        insuTypeList,
                        insuMedTypeList,
                        diseCodeList,
                        birctrlTypeList
                    })
                }
            }
            openModal.destroy();
        } catch (error) {
            message.warning("异常")
            openModal.destroy();
        }
        return
        try {
            let itemselect = this.state.settlementTypeData.filter((item) => {
                return item.id == PayReasonDr;
            })
            let dllInputdata = {
                "params": [{
                    "userID": JSON.parse(window.sessionStorage.userData).userID,
                    "qrCode": this.state.qrCode,
                    "icCardNum": this.state.cardNumber,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID,
                    "patID": this.state.userInfo.patID || '',  //病人id
                    "reasonCode": itemselect[0].code,
                    "patName": this.state.userInfo.patName || '',  //病人姓名
                }],
                "code": "05210036"
            }
            let data = await INSUYBUtil.insuYBAHSYB("ReadYBCard", dllInputdata);         //读医保病人信息
            let res = JSON.parse(data);
            if (res.errorCode == '0') {
                let YBPatDivdata = await INSUYBUtil.GetYBPatDivdata(res.result, PayReasonDr, 'O');    //组织医保病人信息
                if (YBPatDivdata.errorCode == '0') {
                    openModal.destroy();
                    let divdata = YBPatDivdata.result;
                    let comepnCodeList = YBPatDivdata.comepnCodeList
                    this.setState({
                        comepnCodeList,
                        divdata,
                        insuInfoShow: true,
                        readCarddata: res.result
                    })
                }
            }
            else {
                message.warn(res.errorMessage);
                openModal.destroy();
            }
        } catch (error) {
            message.warning("异常:" + error)
            openModal.destroy();
        }
    }
    // 关闭窗口并且 调收银方法
    closeModal = () => {
        let { readCarddata } = this.state;
        this.setState({
            personalData: readCarddata,
            password: '',
            insuInfoShow: false
        })
        this.payButtonData() //;
        this.focusInput()
    }
    payButtonData = async () => {
        let { OPInsuType, insuPayID, PayReasonDr } = this.state
        let itemselect = this.state.settlementTypeData.filter((item) => {
            return item.id == PayReasonDr;
        })
        if (insuPayID != '') {
            let openModal = Modal.info({
                title: "正在进行医保退费,请稍等...",
                content: <Spin size="large" />,
                okText: "",
                onOk() { },
            });
            //医保费用先进行医保退费
            ///医保退费
            let insuData = {
                "params": [{
                    "userID": JSON.parse(window.sessionStorage.userData).userID,
                    "insuPayID": insuPayID,
                    "patID": this.state.userInfo.patID || '',  //病人id
                    "locID": JSON.parse(window.sessionStorage.userData).locID,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                    "ip": React.$getSessionData('ipConfig')?.ipv4 || '',
                    "mac": React.$getSessionData('ipConfig')?.mac || ''
                }]
            }
            let res = await INSUYBUtil.GoTOHISHttp(insuData, "05020012");    //调用his接口
            //let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuOPRefund", dllInputdata);
            openModal.destroy(); // 弹框等待提示
            if (res.errorCode != '0') {
                //医保退费失败
                Keup.ModalMessage(10, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
                return
            }

        }
        var paramsdata = {
            params: [{
                "recordinvID": this.state.recordinvID || '', //收款记录发票记录服务的ID
                "invtype": this.state.invType || '', //类型
                "stopordstr": this.state.refundordIDStr || '', //退费医嘱串
                "newadmreasonID": this.state.PayReasonDr || '', //结算费别来自下拉
                // "repaywID": this.state.refundDefaultPaywayID || '', //新支付方式来自下拉框
                "paytype": 'O' || '', // 类型
                "patpaysum": this.state.payingPatAmt || '', //要退费自付总金额
                personalData: this.state.personalData || ''
            }]
        }
        let hisdataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210021");    //调用his退费接 口
        if (hisdataobj.errorCode != '0') {
            message.warn(hisdataobj.errorMessage);
            return
        }
        var chargeRecodeId = hisdataobj.newpayrecordinfo
        var adminfoArr = hisdataobj.adminfoArr
        this.setState({
            chargeRecodeId: hisdataobj.newpayrecordinfo,
            parkRecordDrinfo: hisdataobj.parkRecordDrinfo,
        }, () => {
            if (!Util.isEmpty(hisdataobj.parkRecordDrinfo)) {
                this.handlePrintAmt(hisdataobj.parkRecordDrinfo)
            }
        })

        ///his退费重收成功
        if ((OPInsuType === 'Y') && (chargeRecodeId != '')) {
            let openModal = Modal.info({
                title: "正在进行医保结算,请稍等...",
                content: <Spin size="large" />,
                okText: "",
                onOk() { },
            });

            /**
             * @ByYQL: 医保结算前进行卡验密
             * Create 2021-12-29
             */
            //----------------------------------------
            message.loading('验密进行中,请提醒患者输入密码...')
            var retStr = await INSUYBUtil.VerfiyPin("{}");
            let resObj = JSON.parse(retStr);
            if (resObj.errorCode != "0") {
                openModal.destroy();
                message.warn(resObj.errorMessage);
                return
            }
            //----------------------------------------

            //医保收费
            //医保确认结算 退费重收就不再进行医保预结算
            let insuData = {
                params: [{
                    "ybPayType": "PAY",  //医保预结算
                    "admID": adminfoArr[0],
                    "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                    "payadmReasonID": PayReasonDr || '', // 结算类型
                    "paytype": "O",
                    "locID": JSON.parse(window.sessionStorage.userData).locID,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                    "ip": React.$getSessionData('ipConfig')?.ipv4 || '',
                    "recordID": chargeRecodeId, //交款记录id
                    "patID": this.state.userInfo.patID || '',  //病人id
                    "mac": React.$getSessionData('ipConfig')?.mac || '',
                    "certNo": this.state.certNo,
                    "certType": this.state.certType,
                }]
            }
            //
            let res = await INSUYBUtil.GoTOHISHttp(insuData, "05020013");    //调用医保正式结算
            //let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuOPPay", insupaydata);
            //let res = JSON.parse(YBPatDivdata);
            openModal.destroy(); // 弹框等待提示
            if (res.errorCode != '0') {
                setTimeout(() => {
                    Keup.ModalMessage(10, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
                }, 1);
            }
        }

        this.setState({
            chargeRecodeId: hisdataobj.newpayrecordinfo,
            parkRecordDrinfo: hisdataobj.parkRecordDrinfo,
        }, () => {
            console.log('弹框出现前chargeRecodeId：', this.state.chargeRecodeId);
            console.log('弹框出现前parkRecordDrinfo：', this.state.parkRecordDrinfo);
            this.setState({
                modalShowPay: true, // 退费弹框
            })
        })
        if (hisdataobj.TinvIDinfo && hisdataobj.TinvIDinfo != '') {
            this.setState({
                invIDinfo: hisdataobj.TinvIDinfo
            }, () => {
                this.print2(hisdataobj.TinvIDinfo)  // 打印
            })
        }
    }

    // 退费弹框
    updateMoney = () => {
        this.handleCancel()  // 关闭弹框

        this.clearnFile() // 清空

        this.initJuris() //权限

        let messageTime = this.state.userData && this.state.userData.messageTime ? this.state.userData.messageTime : 3;
        Keup.ModalMessage(messageTime, this, '成功!', '自动关闭', 'destroy', '确定', 'success');

    }


    // 退费确认
    payButtonOk = () => {


        const { accountPayWayId, payWayCashId, moneyData, cashInCashVal, otherPay, otherPayMoney, otherPayData, unitsListVal } = this.state

        if (parseFloat(otherPayMoney) > 0) {
            if (otherPay === '' || !otherPay) {
                message.error('请选择其他支付方式')
                return false
            }
        }

        if (parseFloat(cashInCashVal) + parseFloat(otherPayMoney) < parseFloat(moneyData.lastPayAmt)) {
            message.error('实付金额小于应付金额')
            return false
        }

        let otherPayCode = otherPayData.filter((item, i) => {
            return item.paywID === otherPay
        })

        if (otherPayCode[0].paywCode === 'CCP') { //合作单位记账
            if (unitsListVal === '' || !unitsListVal) {
                message.error('请选择合作医院')
                return false
            }
        }


        let otherPayStr = otherPay === '' ? '' : otherPay + '^' + parseFloat(parseFloat(moneyData.lastPayAmt) - parseFloat(cashInCashVal)).toFixed(2) //支付方式
        let cashInCashValStr = otherPay === '' ? moneyData.lastPayAmt : cashInCashVal

        this.setState({
            disBtton: true, // 按钮点击许可
        })

        var data1 = {
            params: [{
                "recordIDinfo": this.state.chargeRecodeId || '', // 交款记录id
                "userID": JSON.parse(window.sessionStorage.userData).userID || '', //收费员ID
                "sflag": "0", //是收费还是退费
                "accID": this.state.moneyData.accountID || '', //病人账户ID
                "paywIDinfo": accountPayWayId + '^' + moneyData.payingAccountAmt + String.fromCharCode('2') + payWayCashId + '^' + cashInCashValStr + String.fromCharCode('2') + otherPayStr,//支付方式串
                "printflag": "Y",//是否打印发票
                personalData: this.state.personalData || ''
            }]
        }

        var data2 = {
            params: [{
                "recordIDinfo": this.state.chargeRecodeId || '', // 交款记录id
                "userID": JSON.parse(window.sessionStorage.userData).userID || '', //收费员ID
                "sflag": "0", //是收费还是退费
                "accID": this.state.moneyData.accountID, //病人账户ID
                "paywIDinfo": '',//支付方式串
                "printflag": "Y",//是否打印发票
                personalData: this.state.personalData || ''
            }]
        }

        $http.post('urlADS', this, {
            code: "05210024",
            data: data1,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    $http.post('urlADS', this, {
                        code: "05210007",
                        data: data2,
                        success: function (res) {
                            let errorCode = res.errorCode;
                            if (errorCode === '0') {
                                this.handleCancel()  // 关闭弹框
                                // 清空
                                this.clearnFile()

                                this.initJuris() //权限

                                let messageTime = this.state.userData && this.state.userData.messageTime ? this.state.userData.messageTime : 3;
                                Keup.ModalMessage(messageTime, this, '退费成功!', '自动关闭', 'destroy', '确定', 'success')

                                this.setState({
                                    compleRecordIDinfo: res.compleRecordIDinfo,
                                    invIDinfo: res.invIDinfo
                                }, () => {
                                    this.print2(res.invIDinfo)  // 打印
                                })
                            }
                        }
                    });

                }
            }
        });
    }




    // 实收现金
    cashInCash = (e) => {
        let val = e.target.value

        const { moneyData } = this.state

        this.setState({
            cashInCashVal: Keup.MoneyReplace(val) // 金额过滤
        })


        if (parseFloat(Keup.MoneyReplace(val)) > parseFloat(moneyData.lastPayAmt)) {
            this.setState({
                otherPayDis: true, // 其他支付不可选
                otherPay: '', // 其他支付方式
                otherPayMoney: '0.00', // 其他支付金额
                zeroPay: parseFloat(parseFloat(Keup.MoneyReplace(val)) - parseFloat(moneyData.lastPayAmt)).toFixed(2)// 找零
            })

        } else {
            this.setState({
                otherPayDis: false, // 其他支付不可选
                otherPay: '', // 其他支付方式
                otherPayMoney: '0.00', // 其他支付金额
                zeroPay: '0.00', // 找零
            })
        }
    }



    // 其他支付方式
    otherPay = (e) => {
        this.setState({ otherPay: e });
    }

    // // 其他支付方式
    // refundDefaultPaywayID = (e) => {
    //     this.setState({ refundDefaultPaywayID: e });
    // }

    // 合作单位
    unitsListVal = (e) => {
        this.setState({ unitsListVal: e });
    }



    // 其他支付方式金额
    otherPayMoney = (e) => {
        this.setState({ otherPayMoney: Keup.MoneyReplace(e.target.value) });
        if (parseFloat(Keup.MoneyReplacee(this.state.cashInCashVal)) + parseFloat(Keup.MoneyReplace(e.target.value)) > parseFloat(this.state.moneyData.lastPayAmt)) {
            this.setState({
                zeroPay: parseFloat(Keup.MoneyReplace(this.state.cashInCashVal)) + parseFloat(Keup.MoneyReplace(e.target.value)) - parseFloat(this.state.moneyData.lastPayAmt).toFixed(2)// 找零
            })

        } else {
            this.setState({
                zeroPay: '0.00', // 找零
            })
        }
    }





    // table行样式
    setRowClassName = (record) => {
        return parseFloat(record.applyedQty) > 0 ? 'redTable' : '';
    }

    // 时间
    onChangeTime = (date, dateString) => {
        this.setState({
            StartDate: dateString[0],    //开始日期
            EndDate: dateString[1],  //结束日期
        })

    }


    startChange(date) {
        this.setState({
            StartDate: date,
        })
    }

    endChange(date) {
        this.setState({
            EndDate: date,
        })
    }

    // 打印 原号重打
    print = () => {
        let that = this
        var data = {
            'fpzl': 2,
            'fphm': this.state.fpSource ? this.state.fpSource.fphm : '',//金税发票号码
            'fpdm': this.state.fpSource ? this.state.fpSource.fpdm : '',//金税发票代码
            'showPrintDlg': 0
        }
        var source = encodeURIComponent(JSON.stringify(data))
        var dllInput = 'SID=2\&\&\&\SIDParam=' + source//JSON.stringify({ "SID": "0", "SIDParam": source })
        if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
            // dllInput.path = "1";
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        message.success('打印成功！')
                        // that.loadGoldTaxMessage()
                    }
                })
            }, 100);
        } else {
            $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                input: JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })
            },
                function (data) {
                    var res = JSON.parse(data);
                    if (res.resultCode == '0') {
                        message.success('打印成功！')
                        // that.loadGoldTaxMessage()
                    }
                    // alert(vData);
                });
        }
        // if (this.state.invType === '' || this.state.recordinvID === '') {
        //     message.error('请选择数据')
        //     return false
        // }

        // var data
        // if (this.state.invType === 'INV') {
        //     data = {
        //         params: [{
        //             "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
        //             "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
        //             "printType": "",
        //             "printTemplateCode": "OutInvoice",
        //             "recordIDStr": '',
        //             "invIDStr": this.state.recordinvID || '',
        //             personalData: this.state.personalData || ''
        //         }]
        //     }
        // } else {
        //     data = {
        //         params: [{
        //             "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
        //             "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
        //             "printType": "",
        //             "printTemplateCode": "OutInvoice",
        //             "recordIDStr": this.state.recordinvID || '',
        //             "invIDStr": '',
        //             personalData: this.state.personalData || ''
        //         }]
        //     }
        // }

        // $http.post('urlADS', this, {
        //     code: "05100153",
        //     data: data,
        //     success: function (res) {
        //         let errorCode = res.errorCode;
        //         if (errorCode === '0') {
        //             let dataArr = res.data
        //             let template = res.template
        //             dataArr.map((item, i) => {
        //                 $loadTemplate(template[i], item.toString());

        //             })
        //         }
        //     }
        // });
    }

    handlePrintChargeVoucher(data) {
        var params = {
            params: [{
                recordID: data,
            }]
        }
        $http.post('urlADS', this, {
            code: "05210076",
            data: params,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    if (!Util.isEmpty(this.state.fphm)) {
                        this.handleDelPrint()//当金税发票号码不为空，执行金税作废
                    }
                    let dataArr = res.result
                    dataArr && dataArr.map((item, i) => {
                        $loadTemplate(item.template, item.printStr);
                    })
                }
            }
        });
    }

    //打印退费凭证
    handlePrintAmt(data) {
        var params = {
            params: [{
                recordID: data,
            }]
        }
        $http.post('urlADS', this, {
            code: "05210080",
            data: params,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    let dataArr = res.result
                    dataArr && dataArr.map((item, i) => {
                        $loadTemplate(item.template, item.printStr);
                        $loadTemplate(item.template, item.printStr);
                    })
                }
            }
        });
    }

    // 打印2 作废重打
    print2 = (invIDinfo) => {

        var data = {
            params: [{
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                "printType": "",
                "printTemplateCode": "OutInvoice",
                "recordIDStr": '',
                "invIDStr": invIDinfo || this.state.invIDinfo,
                personalData: this.state.personalData || ''

            }]
        }

        $http.post('urlADS', this, {
            code: "05100153",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    if (!Util.isEmpty(this.state.fphm)) {
                        this.handleDelPrint()//当金税发票号码不为空，执行金税作废
                    }
                    let dataArr = res.data
                    let template = res.template
                    dataArr.map((item, i) => {
                        $loadTemplate(template[i], item.toString());
                    })
                }
            }
        });
    }

    handleDelPrint() {
        // let that = this
        // var data = {
        //     'fpzl': 2,
        //     'fphm': this.state.fpSource ? this.state.fpSource.fphm : '',//金税发票号码
        //     'fpdm': this.state.fpSource ? this.state.fpSource.fpdm : '',//金税发票代码
        // }
        // fetchJsonp('http://127.0.0.1:9999/InvSvr?SID=4' + '&SIDParam=' + encodeURIComponent(data), {
        //     jsonpCallback: 'JsonCallback',
        // })
        //     .then(function (response) {
        //         return response.json()
        //     }).then(function (json) {

        //         json = decodeURIComponent(JSON.parse(json))
        //         if (json.errorCode == "0") {
        //             console.dir('金税作废成功')
        //         } else {
        //             message.error(json.errorMessage);
        //         }

        //         return json

        //     }).catch(function (ex) {
        //         return false
        //     })
        let that = this
        var data = {
            'fpzl': 2,
            'fphm': this.state.fpSource ? this.state.fpSource.fphm : '',//金税发票号码
            'fpdm': this.state.fpSource ? this.state.fpSource.fpdm : '',//金税发票代码
        }
        var source = encodeURIComponent(JSON.stringify(data))
        var dllInput = 'SID=4\&\&\&\SIDParam=' + source//JSON.stringify({ "SID": "0", "SIDParam": source })
        if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
            // dllInput.path = "1";
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        message.success('作废成功！')
                    }
                })
            }, 100);
        } else {
            $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                input: JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })
            },
                function (data) {
                    var res = JSON.parse(data);
                    if (res.resultCode == '0') {
                        message.success('作废成功！')
                    }
                    // alert(vData);
                });
        }
    }

    // 费用类型table
    ordList1 = () => {
        let data = {
            params: [{
                "reactCode": ["PatientRefund"],
                "compontName": "PatientRefund",
                "type": "C"

            }]
        }
        $http.post('urlS', this, {
            code: "01040073",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.setState({
                        columns: res.result.C || {},  // 国际化Table2
                        languageData: res.result.language || {},  // 国际化语言包
                    }, () => {
                        this.LanCNEN(this.state.languageCode)
                        this.cloumData1(this.state.columns)
                    })
                }
            }
        });
    }

    LanCNEN = (code) => {
        let { languageData } = this.state
        this.setState({
            language: languageData[code]
        })
    }

    // 数据配置
    cloumData1(resC) {

        let { languageCode } = this.state
        for (var i = 0; i < resC.length; i++) {
            resC[i].key = i;
        }
        if (languageCode === "EN") {
            resC.map((item, i) => {
                item.title = item.enDescripts
            })
        }

        if (languageCode === "CN") {
            resC.map((item, i) => {
                item.title = item.descripts
            })
        }

        this.setState({
            columns: resC, // 费用类型table
        });
    }
    modalOnRef = (ref) => {
        this.modalChild = ref
    }
    // 诊断回车事件
    itmOnPressEnter = () => {
        let top = document.getElementById('inputDiag-id').getBoundingClientRect().top + 30 + 'px';
        let left = document.getElementById('inputDiag-id').getBoundingClientRect().left + 'px';
        this.setState({
            top,
            left
        });
        this.getModalListData(this.state.searchCode);
        //
    }
    itmOnChange = (e) => {
        if (!e.target.value) {
            this.setState({
                searchCode: '',
                INSUICDDesc: '',
                INSUICDCode: ''
            })
        } else {
            this.setState({ searchCode: e.target.value })
        }
    }
    // 修改结算类型
    comepnCodeonChange = (val, opt) => {
        this.setState({
            comepnCode: val,
        });
    }
    handleCompilePage = (page, pageSize) => {
        this.setState({ modalPageSize: pageSize, modalPage: page }, () => {
            this.getModalListData(this.state.searchCode);
        })
    }

    // 获取描述列表数据
    getModalListData(searchCode) {
        let { modalPageSize, modalPage, pageSize, page, admReasomID } = this.state;
        let data = {
            params: [
                {
                    searchCode: searchCode,
                    admReasomID,
                    treatCode: (treatCode),			//
                }
            ],
            pagination: [{
                pageSize: modalPageSize,
                currentPage: modalPage,
                sortColumn: "Describe",
                sortOrder: "asc"
            }]
        }
        $http.post('urlS', this, {
            code: "05210068",
            data: data,
            success: function (res) {
                if (res.errorCode == '0') {
                    var source = res.result.data
                    for (var i = 0; i < source.length; i++) {
                        source[i].key = i + 1
                    }
                    this.setState({ modalData: source, modalTotal: res.result.totalCount }, () => {
                        this.modalChild.showModal();
                    })
                } else {
                    this.setState({ modalData: [], modalTotal: 0 })
                }
            }
        })
    }

    // 下拉table双击
    onClickRowPublic = (record) => {
        return {
            onDoubleClick: () => {
                this.setState({
                    INSUICDCode: record.code,
                    INSUICDDesc: record.descripts,
                    searchCode: ''
                }, () => this.modalChild.handleCancel())
            }
        }

    };

    setRowClassNamePublic = () => {
        // return (record.id) === this.state.diagID ? 'clickRowStyle' : '';
    };

    // 就诊凭证类型
    certTypeonChange = (val, opt) => {
        this.setState({
            certType: val,
        });
    };

    // 就诊凭证编号
    certNoChange = e => {
        this.setState({ certNo: e.target.value })
    };

    //统筹区
    // insuAdmdvsonChange = (val, opt) => {
    //     this.setState({
    //         insuAdmdvs: val,
    //     });
    // };

    render() {
        let { userInfo, moneyData, language, modalTotal, modalPage, top, left, modalData, PayReasonDr } = this.state
        const setRowClassName = this.setRowClassName
        const modalParam = {
            width: '600px',
            total: modalTotal,
            page: modalPage,
            top: top,
            left: left,
            columns: this.modalColumns,
            data: modalData,
            isOnRow: true,
            showPagination: true,
        }

        return (
            <div>
                {/**列input框新表格弹框 */}
                <PublicModalTable
                    onClickRowPublic={this.onClickRowPublic}
                    setRowClassNamePublic={this.setRowClassNamePublic}
                    param={modalParam}
                    onRef={this.modalOnRef}
                    compilePage={this.handleCompilePage}
                />
                <ReadCard ref={r => this.readCard = r} />
                <div >
                    <Row>

                        <Col span={6} style={{ textAlign: 'center', }} >
                            <Row >
                                <Col span={23} >
                                    <TipHeader userInfo={userInfo} key={userInfo.patID + this.state.userInfo.accTSubID} />
                                </Col>
                            </Row>
                            <Row style={{ height: '203px' }}>
                                <Col span={23}>
                                    {this.state.groupConfig && this.state.groupConfig.IfInvNo === 'Y' ?
                                        <Col span={24} style={{ height: '40px', lineHeight: '40px', textAlign: 'left' }} ><i className="invPng"></i><span>{language.PatientRefundCurrentInvoiceID && language.PatientRefundCurrentInvoiceID.descripts}:</span><span className='curP' style={{ color: '#1890FF', }}  > {this.state.invoice ? this.state.invoice.split('^')[2] : ''}</span> <span style={{ color: 'red', float: 'right', marginRight: '20px', display: parseFloat(this.state.invNum) < 10 ? 'block' : 'none' }}>{language.PatientChargesInvoicesurplus && language.PatientChargesInvoicesurplus.descripts}{this.state.invNum},{language.PatientChargesPleasepurch && language.PatientChargesPleasepurch.descripts}</span></Col>
                                        : ""
                                    }

                                    <Col span={12} >
                                        <div className='boxTitle'><i className="money1"></i>{language.PatientRefundRefundTotalAmount && language.PatientRefundRefundTotalAmount.descripts}</div>
                                        <div className='priceBox'>
                                            <span style={{ fontSize: '12px', color: '#CCCCCC' }}>￥</span> <span>{this.state.refundPatAmt} </span>
                                        </div>

                                    </Col>
                                    <Col span={12}  >
                                        <div className='boxTitle'><i className="money2"></i>{language.PatientRefundRemainsBhouldBePaid && language.PatientRefundRemainsBhouldBePaid.descripts}</div>
                                        <div className='priceBox'>
                                            <span style={{ fontSize: '12px', color: '#CCCCCC' }}>￥</span> <span>{this.state.payingPatAmt} </span>
                                        </div>

                                    </Col>
                                    <Col span={24} className="mT15" >
                                        <Col style={{ float: 'left' }}> <span style={{ lineHeight: '32px', margin: '0 10px' }}>{language.PatientRefundBillingType && language.PatientRefundBillingType.descripts}:</span></Col>
                                        <Col span={10} >
                                            <Select style={{ width: "100%" }} allowClear placeholder={language.PatientRefundBillingType && language.PatientRefundBillingType.descripts} value={this.state.PayReasonDr} onChange={(event) => { this.PayReasonDr(event) }} >
                                                <Option value=''>请选择</Option>
                                                {this.state.settlementTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                            </Select>
                                        </Col>
                                    </Col>
                                </Col>
                            </Row>
                            <Col span={1}
                                style={{
                                    height: '100%',
                                    background: 'rgb(240, 242, 245)',
                                    float: 'right',
                                    position: 'absolute',
                                    right: '0px',
                                    top: '0px'
                                }} >
                            </Col>
                        </Col>
                        <Col span={18} style={{ padding: 10 }} >
                            <div className="table-operations">
                                <Row style={{ minHeight: '50px', paddingBottom: '10px' }}>
                                    <Col span={24}>
                                        <Select allowClear style={{ width: '100px', margin: '12px 15px 0 0' }} placeholder="请选择" value={this.state.cardType} onChange={(event) => { this.cardType(event) }} >
                                            <Option value=''>请选择</Option>
                                            {this.state.cardTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                        </Select>
                                        <Search maxLength={50} className={`search ${!this.state.readModeI ? 'disabled' : ''}`} style={{ width: '200px', margin: '12px 15px 0 0' }} allowClear placeholder={language.PatientRefundLoadCard && language.PatientRefundLoadCard.message} value={this.state.cardNo} enterButton={language.PatientRefundLoadCard && language.PatientRefundLoadCard.descripts} onChange={(event) => { this.cardNo(event) }} onSearch={this.handleReadCard} />
                                        {/* <Button style={{ background: 'rgba(66,185,131,1)', color: '#fff', width: '100px', margin: '12px 15px 0 0' }} onClick={() => { this.searchUser('cardNo') }} >读卡</Button> */}
                                        {language.PatientRefundPersonIdentification && language.PatientRefundPersonIdentification.descripts}：<Input maxLength={50} style={{ width: '200px', margin: '12px 15px 0 0' }} ref={(input) => { this.patNoInput = input; }} allowClear placeholder={language.PatientRefundPersonIdentification && language.PatientRefundPersonIdentification.message} className='input' value={this.state.patNo} onChange={(event) => { this.patNo(event) }} onKeyUp={(e) => { this.patNodownE(e, 'patNo'); }} />
                                        {/* 就诊日期：<RangePicker style={{ width: '260px', margin: '12px 15px 0 0' }}
                                value={this.state.StartDate === undefined || this.state.EndDate === undefined || this.state.StartDate === "" || this.state.EndDate === "" ? null : [moment(this.state.StartDate, dateFormat), moment(this.state.EndDate, dateFormat)]}
                                format={dateFormat}
                                onChange={this.onChangeTime} /> */}
                                        {language.PatientRefundInvoiceNumber && language.PatientRefundInvoiceNumber.descripts}: <Input maxLength={50} style={{ width: '200px', margin: '12px 15px 0 0' }} allowClear placeholder={language.PatientRefundInvoiceNumber && language.PatientRefundInvoiceNumber.message} className='input' value={this.state.invNo} onChange={(event) => { this.invNo(event) }} onKeyUp={(e) => { this.patNodownE(e, 'invNo'); }} />

                                        <span style={{ display: 'inline-block', margin: '12px 15px 0 0' }}><RangeDatePicker label={`${language.PatientRefundChargeDate && language.PatientRefundChargeDate.descripts}：`} format='YYYY-MM-DD' width={280}
                                            startDate={this.state.StartDate} endDate={this.state.EndDate} startChange={this.startChange.bind(this)} endChange={this.endChange.bind(this)} /></span>
                                        <Button onClick={() => this.searchUser()} style={{ margin: '12px 15px 0 0', background: 'rgba(255,255,255,1)' }}>{language.PatientRefundQuery && language.PatientRefundQuery.descripts}</Button>
                                    </Col>
                                </Row>
                            </div>
                            <div style={{ padding: '0 12px' }}>
                                <InquiryFeeRecordModal userInfo={this.state.userInfo} updateParent={this.updateParent} type='refund' StartDate={this.state.StartDate} EndDate={this.state.EndDate} invNum={this.state.invNo} key={this.state.invNo} ></InquiryFeeRecordModal>
                            </div>
                        </Col>
                    </Row>
                    <div style={{ background: '#f0f2f5', height: '10px' }}></div>
                    <Row style={{ padding: '0 24px' }}>
                        <Col span={24}>
                            <div style={{ float: 'left', lineHeight: '37px' }}>
                                <Icon type="exclamation-circle" theme="filled" style={{ color: '#FA8C16', margin: '0 10px' }} />
                                {language.PatientRefundTips && language.PatientRefundTips.descripts}
                            </div>

                            <div style={{ float: 'right' }}>
                                <Button onClick={() => { this.clearnFile() }} style={{ float: 'left', border: 'none', marginLeft: ' 20px', }}><i className="clearn"></i>{language.PatientRefundClear && language.PatientRefundClear.descripts}</Button>
                                {Util.isEmpty(this.state.fphm) ?
                                    <Tooltip title='金税发票未打印'><Button disabled={Util.isEmpty(this.state.fphm)}
                                        style={{ float: 'left', border: 'none', marginLeft: ' 20px', }}><i className="printing"></i>
                                        {language.PatientRefundPrintAgain && language.PatientRefundPrintAgain.descripts}</Button></Tooltip>
                                    :
                                    <Button onClick={() => { this.print() }} style={{ float: 'left', border: 'none', marginLeft: ' 20px', }}><i className="printing"></i>{language.PatientRefundPrintAgain && language.PatientRefundPrintAgain.descripts}</Button>}

                                {this.state.disInvType !== 'PAY' ? <Tooltip title='发票已打印，请先到发票查询页面作废！'>
                                    <Button onClick={this.payButton} disabled={this.state.disBtton || this.state.disInvType !== 'PAY'}
                                        style={{ float: 'left', border: 'none', marginLeft: '20px', display: this.state.payReasonDesc === '' ? 'none' : 'block' }}>
                                        <i className="f1"></i>{this.state.payReasonDesc}</Button></Tooltip> :
                                    <Button onClick={this.payButton} disabled={this.state.disBtton || this.state.disInvType !== 'PAY'}
                                        style={{ float: 'left', border: 'none', marginLeft: '20px', display: this.state.payReasonDesc === '' ? 'none' : 'block' }}>
                                        <i className="f1"></i>{this.state.payReasonDesc}</Button>}
                            </div>
                        </Col>
                        <Col span={24}>
                            <Table
                                className='maxHeight'
                                bordered
                                dataSource={this.state.dataTable}
                                columns={this.state.columns}
                                pagination={false}
                                style={{ minHeight: (store.getState().tableHeight.y) - 200 + 'px' }}
                                scroll={{ y: (store.getState().tableHeight.y) - 200, x: 1750 }}
                                rowClassName={setRowClassName}
                            />
                        </Col>

                    </Row>

                    {/* 作废时判断是否确认作废 */}
                    <Modal
                        visible={this.state.modalShowDeletePay}
                        title='操作确认'
                        width='600px'
                        className='modalPay'
                        closable={true}
                        maskClosable={true}
                        onCancel={this.payButtonModalCancel}
                        footer={null}>
                        <p>{'请确认此单是否进行' + this.state.payReasonDesc + '处理？'}</p>
                        <div style={{ textAlign: 'right', margin: '40px 0 10px 0' }}>
                            <Button onClick={this.payButtonModalCancel} style={{ background: 'rgba(0,0,0,0.3)', color: '#fff', marginRight: '10px' }}>取消</Button>
                            <Button onClick={this.payButtonModal} style={{ background: 'rgba(66,185,131,1)', color: '#fff' }}>确认</Button>
                        </div>
                    </Modal>


                    {/* 作废重收 */}
                    <Modal
                        visible={this.state.modalShowPay}
                        title={this.state.payReasonDesc == '作废' ? '已作废,点击确认关闭' : this.state.payReasonDesc}
                        width='900px'
                        className='modalPay'
                        closable={false}
                        keyboard={false}
                        footer={null}
                    // onOk={this.payvData}
                    >
                        {/* 子组件key值此处原代码使用chargeRecodeId，而接口反参里chargeRecodeId的取值为空，因为导致第二次打开子组件时不会重新渲染不会进入componentDidMount，因此显示内容还是上次的内容 */}
                        <WasteAndReclaimed key={this.state.parkRecordDrinfo} handelThis={this} updateMoney={this.updateMoney} recordinvID={this.state.recordinvID} invType={this.state.invType} parkRecordDrinfo={this.state.parkRecordDrinfo} chargeRecodeId={this.state.chargeRecodeId} ></WasteAndReclaimed>
                    </Modal>

                    <Modal
                        title="请输入医保卡号或扫描电子凭证医保码"
                        visible={this.state.cardShow}
                        onOk={this.YBInputSure}
                        onCancel={() => this.setState({ cardShow: false })}>
                        <Row style={{ marginTop: '10px' }}>
                            <Col span={6} style={{ paddingTop: '4px' }}>就诊凭证类型:</Col>
                            <Col span={18}>
                                <Select style={{ width: '320px' }} value={this.state.certType} onChange={this.certTypeonChange} >
                                    <Option value='01'>电子凭证令牌</Option>
                                    <Option value='02'>身份证号</Option>
                                    <Option value='03'>社会保障卡</Option>
                                </Select>
                            </Col>
                        </Row>
                        <Row style={{ marginTop: '10px' }}>
                            <Col span={6} style={{ paddingTop: '4px' }}>就诊凭证编号:</Col>
                            <Col span={18}><Input style={{ width: '320px' }} value={this.state.certNo} onChange={(e) => this.certNoChange(e)} onPressEnter={this.YBInputSure} /></Col>
                        </Row>
                        {/*<Row style={{ marginTop:'10px' }}>*/}
                        {/*    <Col span={6} style={{ paddingTop:'4px' }}>统筹区:</Col>*/}
                        {/*    <Col span={18}>*/}
                        {/*        <Select style={{ width: '320px'}} value={this.state.insuAdmdvs} onChange={this.insuAdmdvsonChange} showSearch optionFilterProp="seatchprop" allowClear >*/}
                        {/*            {this.state.insuAdmdvsList && Array.isArray(this.state.insuAdmdvsList) && this.state.insuAdmdvsList.map((item, index) => <Option title={item.descripts} key={index} value={item.code} seatchprop={item.descripts + '^' + item.descriptsSPCode}>{item.descripts}</Option>)}*/}
                        {/*        </Select>*/}
                        {/*    </Col>*/}
                        {/*</Row>*/}
                    </Modal>

                    <Modal
                        title='医保病人信息'
                        visible={this.state.insuInfoShow}
                        onCancel={() => this.setState({ insuInfoShow: false })}
                        okText="确定"
                        onOk={this.closeModal}
                        width={1000}
                    >
                        <div>
                            <Row className="ybpat-row">
                                {this.state.divdata.map((item, index) => {
                                    return <Col className="ybpat-col" span={6} key={index}>
                                        <span className="ybpat-desc">{item.desc}</span>
                                        <span>：</span>
                                        <span className="ybpat-value">{item.value}</span>
                                    </Col>
                                })}
                            </Row>
                            <Row className="ybpat-row">
                                <Col className="ybpat-col" span={8} key={1}>
                                    <div><span className="ybpat-desc">结算类型</span>
                                        <span>：</span>
                                        <span className="ybpat-value">
                                            <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.comepnCode} onChange={this.comepnCodeonChange} >
                                                {this.state.comepnCodeList.map((item, index) => <Option title={item.subDesc} key={index} value={item.subCode} >{item.subDesc}</Option>)}
                                            </Select>
                                        </span>
                                    </div>
                                    {/* } */}
                                </Col>
                                <Col className="ybpat-col" span={8} key={5}>
                                    <div><span className="ybpat-desc">ICD诊断</span>
                                        <span>：</span>
                                        <span className="ybpat-value">
                                            <Input
                                                style={{ width: '200px', margin: '12px 15px 0 0' }}
                                                id='inputDiag-id'
                                                placeholder='输入后回车搜索'
                                                onPressEnter={this.itmOnPressEnter}
                                                value={this.state.searchCode ? this.state.searchCode : this.state.INSUICDDesc}
                                                onChange={this.itmOnChange}
                                                allowClear
                                            />
                                        </span>
                                    </div>
                                </Col>
                            </Row>
                        </div>
                    </Modal>
                </div>
            </div>
        )
    }
}
